using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Options;
using Test.WebApi.SQLite.common;

namespace Test.WebApi.SQLite.Controllers
{
    [ApiController]
    [Route("[controller]/[action]")]
    public class WeatherForecastController : ControllerBase
    {
        private readonly IConfiguration _configuration;
        private readonly IOptionsSnapshot<LogConfig> _logConfig;

        public WeatherForecastController(IConfiguration configuration, IOptionsSnapshot<LogConfig> logConfig)
        {
            _configuration = configuration;
            _logConfig = logConfig;
        }

        [HttpGet(Name = "getWeatherForecast")]
        public IActionResult Get()
        {
            var a = _configuration.GetSection("AllowedHosts").Value;
            var b = _configuration.GetSection("Logging:LogLevel:Default").Value;
            var c = _configuration.GetSection("Logging:LogLevel:Microsoft.AspNetCore").Value;
            var d = _logConfig.Value.ApiUri;
            var e = System.Text.Json.JsonSerializer.Serialize(_logConfig.Value);
            var f = _configuration.GetSection("log:logFilePath").Value;
            var g = _configuration.GetSection("log").Value;
            var h = _configuration.GetSection("log").Get<LogConfig>();
            return Ok();
        }

        [HttpGet(Name = "getTest")]
        public IActionResult GetTest()
        {
            var a = ConfigHelper.GetSectionValue("Api:Jwt:Audience").Value;
            var b = ConfigHelper.GetSectionValue("Logging:LogLevel:Default").Value;
            var c = ConfigHelper.GetSectionValue("Logging:LogLevel:Microsoft.AspNetCore");
            var f = ConfigHelper.GetSectionValue("log:logFilePath").Value;
            var g = ConfigHelper.GetSectionValue("log");
            var h = ConfigHelper.GetSectionValue("log").Get<LogConfig>();
            return Ok();
        }

        [HttpGet(Name = "getValue")]
        public IActionResult GetValue(string value)
        {
            var temp = ConfigHelper.GetSectionValue(value).Value;
            return Ok(temp);
        }
    }
}